﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using DataAccess;
using DevExpress.XtraEditors;
using DevExpress.XtraReports.UI;
using QuanLyKhachSan.TemplateReport;

namespace QuanLyKhachSan
{
    public partial class FormInChiTietHoaDonTheoKH : XtraForm
    {
        private decimal gimaGia = 0;

        public FormInChiTietHoaDonTheoKH(List<ChiTietHoaDonDichVu> listChiTiet )
        {
            InitializeComponent();
            dgvChiTietHoaDon.DataSource = listChiTiet;
        }
        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void FormInChiTietHoaDonTheoKH_Load(object sender, EventArgs e)
        {

        }

        private List<ChiTietHoaDonDichVu> GetDataListOrdersDetail()
        {
            var rs = new List<ChiTietHoaDonDichVu>();
            for (int i = 0; i < gridView1.DataRowCount; i++)
            {
                var detail = gridView1.GetRow(i) as ChiTietHoaDonDichVu;
                rs.Add(detail);
            }
            return rs;
        }

        private List<ChiTietHoaDonDichVu> GetListOrderDetails()
        {
            var rs = new List<ChiTietHoaDonDichVu>();
            for (int i = 0; i < gridView1.DataRowCount; i++)
            {
                try
                {
                    var ct = gridView1.GetRow(i) as ChiTietHoaDonDichVu;
                    rs.Add(ct);
                    gimaGia += Convert.ToDecimal(ct.SoLuong*ct.DichVu.Gia*(ct.DichVu.GiamGia/100));
                }
                catch (Exception)
                {
                }
            }
            return rs;
        }

        private void btnInDS_Click(object sender, EventArgs e)
        {
            List<ChiTietHoaDonDichVu> rs = GetListOrderDetails();
            var phieuThu = new XtrpPhieuThuDV(rs);

            var frm = new FormReport(phieuThu);
            frm.ShowDialog();


        }
    }
}
